﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App.Validate
{
    public abstract class CompositeValidatorAttribute : ValidatorAttribute
    {        
        public IEnumerable<string> ValidatorElements { get; private set; }

        public CompositeValidatorAttribute(string messageTemplate, string validatorElements):base(messageTemplate)
        {
            Guard.ArgumentNotNullOrEmpty(validatorElements, "validatorElements");
            this.ValidatorElements = ConvertToList(validatorElements);
        }

        private IEnumerable<string> ConvertToList(string validatorElements)
        {
            foreach (var element in validatorElements.Split(','))
            {
                yield return element;
            }
        }

        public abstract CompositeValidator CreateCompositeValidator(IEnumerable<Validator> validator);

        public override Validator CreateValidator()
        {
            throw new NotImplementedException();
        }
    }
}